home *** CD-ROM | disk | FTP | other *** search
/ Magnum One / Magnum One (Mid-American Digital) (Disc Manufacturing).iso / d12 / v10n01.arc / BIOSDATA.PAS < prev    next >
Pascal/Delphi Source File  |  1990-12-11  |  4KB  |  110 lines

  1.  
  2. {******************************************************************************
  3.  *                                                                            *
  4.  *         PC MAGAZINE'S INTERACTIVE READER OF THE BIOSDATA  REGION           *
  5.  *               Copyright (c) 1990 Ziff Communications Co.                   *
  6.  *                      written by Barry Simon                                *
  7.  *                                                                            *
  8.  *****************************************************************************}
  9.  
  10. USES CRT, DOS;
  11.  
  12. CONST
  13.   HexDigits : ARRAY[0..15] OF Char = '0123456789ABCDEF';
  14.  
  15.   FUNCTION ByteToHex(B : Byte) : STRING;
  16.     {Changes byte to hex string}
  17.   BEGIN
  18.     ByteToHex := HexDigits[B DIV 16]+HexDigits[B MOD 16];
  19.   END;
  20.  
  21. TYPE
  22.   ByteLine = ARRAY[0..15] OF Byte; {display as one line}
  23.   BytePage = ARRAY[0..15] OF ByteLine; {display ful 256 bytes}
  24.  
  25. VAR
  26.   BiosArea : BytePage ABSOLUTE $0000 : $0400;
  27.   {by allowing type usage, this is better then using the Mem array}
  28.   CurH, CurL : Byte;
  29.   Regs : Registers;
  30.  
  31.   PROCEDURE HideCursor;
  32.   BEGIN
  33.     WITH Regs DO BEGIN
  34.       AH := 3;                    {read cursor info}
  35.       BH := 0;                    {assume page 0}
  36.       intr($10, Regs);
  37.       CurH := CH; CurL := CL;     {save cursor info}
  38.       AH := 1;                    {set Cursor Shape}
  39.       CX := $2000;                {hide cursor}
  40.       intr($10, Regs);
  41.     END;
  42.   END;
  43.  
  44.   PROCEDURE RestoreCursor;
  45.   BEGIN
  46.     WITH Regs DO BEGIN
  47.       CH := CurH; CL := CurL;     {restore cursor info}
  48.       AH := 1;                    {set Cursor Shape}
  49.       intr($10, Regs);
  50.     END;
  51.   END;
  52.  
  53.   FUNCTION ShowByteLine(B : ByteLine; j : Integer) : STRING;
  54.   CONST
  55.     specialchars : SET OF Byte = [7, 8, 10, 13];
  56.     {needed because Turbo displays these characters as screen actions}
  57.   VAR
  58.     i : Byte;
  59.     s : STRING;
  60.   BEGIN
  61.     s := '0040:00'+Char($30+j+7*(j DIV 10))+'0 │ ';
  62.         {the $30+n is ASCII for n for n=0,..,9.  The 7*(j div 10) adjusts
  63.           for 10 to become A,...,15 to become F}
  64.     FOR i := 0 TO 15 DO BEGIN
  65.       s := s+ByteToHex(B[i])+' ';
  66.       {IF ((i MOD 4) = 3) THEN s := s+' ';}
  67.     END;
  68.     s := s+'│';
  69.     FOR i := 0 TO 15 DO IF (B[i] IN specialchars) THEN
  70.       s := s+' '
  71.       ELSE s := s+Char(B[i]);
  72.     ShowByteLine := s;
  73.   END;
  74.  
  75.   FUNCTION EscHit : Boolean;
  76.   VAR
  77.     R : Registers;
  78.   BEGIN
  79.     WITH R DO BEGIN
  80.       {use service 0 of int 16 to check for Escape}
  81.       AH := 00;
  82.       intr($16, R);
  83.       IF AL = 27 {escape} THEN EscHit := True ELSE EscHit := False;
  84.     END;
  85.   END;
  86.  
  87. VAR
  88.   j : Byte;
  89.   C : ByteLine;
  90.  
  91. BEGIN
  92.   textattr := $0F;
  93.   HideCursor;
  94.   Clrscr;
  95.   gotoXY(1, 2);
  96.   WriteLn('═══════════════════════════════════════════════════════════════════════════════');
  97.   WriteLn('                 PC Magazine''s Interactive BIOS DATA AREA Reader               ');
  98.   WriteLn('                   Copyright (c) 1990 Ziff Communications Co.                 ');
  99.   WriteLn('──────────┬─────────────────────────────────────────────────┬──────────────────');
  100.   gotoXY(1, 22);
  101.   WriteLn('══════════╧═════════════════════════════════════════════════╧══════════════════');
  102.   WriteLn('                                Hit <Esc> to Exit');
  103.   WHILE True DO BEGIN
  104.     gotoXY(1, 6);
  105.     FOR j := 0 TO 15 DO WriteLn(ShowByteLine(BiosArea[j], j));
  106.     IF keypressed THEN
  107.       IF EscHit THEN BEGIN RestoreCursor; gotoXY(80, 24); Halt; END;
  108.   END;
  109. END.
  110.